package pack0708.com;

public class Test1 {
    public static void main(String[] args) {

        //写法一:
        Fruit f = (age) -> System.out.println("苹果");
        f.showcolor("age");

        //写法二:当只有一个参数时,()可以省略
        Fruit f1 = age -> System.out.println("梨");
        f1.showcolor("name");

        //写法三:当方法体多于一句,必须加上大括号
        Fruit f2 = age -> {
            System.out.println("name");
            System.out.println("name是啥");
        };
        f2.showcolor("age");

        //写法四:当方法体只有一句,name省略了大括号,也省略了return,直接写表达式即可
        //参数多于一个,小括号就不能省略了
        People p = (name, age) -> name + "" + age;
        String s = p.say("你好", 12);
        System.out.println(s);

        //写法五:方法体多于1句,此时不能省略大括号,return也不能省略了
        People p1 = (name, age) -> {
            System.out.println(name + ",你好");
            return name + age;
        };
        String s1 = p1.say("世界", 23);
        System.out.println(s1);
    }
}
